package gold.digger;

import java.util.*;
import java.util.List;
import java.util.Queue;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC559 {
    public long startExecuteTime = System.currentTimeMillis();

    class Node {
        public int val;
        public List<Node> children;

        public Node() {
        }

        public Node(int _val) {
            val = _val;
        }

        public Node(int _val, List<Node> _children) {
            val = _val;
            children = _children;
        }
    }

    class Solution {
        public int maxDepth(Node root) {
            if (null == root) return 0;
            Queue<Node> queue = new LinkedList<>();
            queue.offer(root);
            Node cur;
            int depth = 0;

            while (!queue.isEmpty()) {
                ++depth;
                int size = queue.size();
                for (int i = 0; i < size; i++) {
                    cur = queue.poll();
                    for (Node child : cur.children) {
                        queue.offer(child);
                    }
                }
            }

            return depth;
        }
    }

    public void run() {
        Solution solution = new Solution();
        List<Integer> list = new ArrayList<>();
        System.out.println(solution.toString());
    }

    public static void main(String[] args) throws Exception {
        LC559 an = new LC559();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
